import 'package:event_bus/event_bus.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:rxdart/rxdart.dart';

///普通事件
EventBus eventBus = new EventBus();

///可用于黏性事件
EventBus behaviorBus = EventBus.customController(BehaviorSubject());

/// 全局NavigatorKey
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();

///显示Toast消息
enum ToastType { success, error }

void showToast(String message, {ToastType type = ToastType.success}) {
  var color = Colors.red;
  switch (type) {
    case ToastType.success:
      color = Colors.green;
      break;
    case ToastType.error:
      color = Colors.red;
      break;
  }
  Fluttertoast.showToast(msg: message, backgroundColor: color, gravity: ToastGravity.BOTTOM);
}

///是否debug环境
final isDebug = true;

///判断程序当前的运行环境
bool inProduct() {
  return const bool.fromEnvironment("dart.vm.product");
}
